﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CMN.BLL;
using CMN.Common;
using CMN.Entity;
using CMN.Models.Interfaces;
namespace CMN.Models
{
    /// <summary>
    /// 视频Service
    /// </summary>
    public class Module_VideoService: IDataService<Module_VideoEntity>
    {
        /// <summary>
        /// 新增视频
        /// </summary>
        /// <param name="Module_VideoEntity"></param>
        /// <returns>bool</returns>
        public string Insert(Module_VideoEntity module_videoEntity)
        {
            Module_Video bll = new Module_Video();
            module_videoEntity.DataTable_Action = DataTableAction.Insert;
            if (bll.InsertUpdateDelete(module_videoEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 返回视频查询列表
        /// </summary>
        /// <param name="qp"></param>
        /// <param name="count">查询总个数</param>
        /// <returns>List</returns>
        public List<Module_VideoEntity> List(QueryParam qp,out int count)
        {
            Module_Video bll = new Module_Video();
            return bll.List(qp, out count);
        }

        /// <summary>
        /// 更新视频
        /// </summary>
        /// <param name="Module_Video"></param>
        /// <returns>bool</returns>
        public string Update(Module_VideoEntity module_videoEntity)
        {
            Module_Video bll = new Module_Video();
            module_videoEntity.DataTable_Action = DataTableAction.Update;
            if (bll.InsertUpdateDelete(module_videoEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 删除视频
        /// </summary>
        /// <param name="Module_Video"></param>
        /// <returns>bool</returns>
        public string Delete(Module_VideoEntity module_videoEntity)
        {
            Module_Video bll = new Module_Video();
            module_videoEntity.DataTable_Action = DataTableAction.Delete;
            if (bll.InsertUpdateDelete(module_videoEntity) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }
        }

        /// <summary>
        /// 批量删视频
        /// </summary>
        /// <param name="idList">删除id列表  2_8_9_45</param>
        /// <returns>bool</returns>
        public string DeleteList(string idList)
        {
            Module_Video bll = new Module_Video();
            string[] list =Utils.SplitString(idList,"_");
            string strDel=Utils.ArrayToString(list,",",false);
            if (bll.DelList(strDel) > 0)
            {
                return "";
            }
            else
            {
                return "失败";
            }

        }

        /// <summary>
        /// 返回单个视频
        /// </summary>
        /// <param name="id"></param>
        /// <returns>Module_VideoEntity</returns>
        public Module_VideoEntity Look(int id)
        {
            Module_Video bll = new Module_Video();
            return bll.Disp(id);
        }
    }
}
